//
//  caseHoraire.m
//  testPlanning
//
//  Created by richard_local on 04/09/13.
//  Copyright (c) 2013 ierdre.com. All rights reserved.
//

#import "caseHoraire.h"

@implementation caseHoraire

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self.layer setBorderWidth:4.0];
        [self.layer setCornerRadius:10.0];
        [self.layer setBorderColor:[[UIColor blackColor] CGColor]];
         }
    return self;
}




// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    
    
    
   /* [self.layer setBorderWidth:2.0];
    [self.layer setCornerRadius:0.0];
    [self.layer setBorderColor:[[UIColor blackColor] CGColor]];*/
   // [self setBackgroundColor:[UIColor whiteColor] ];
    
    int r = arc4random() % 3;
    UIImage *imageOK = [UIImage imageNamed:@"green.jpg"];
    UIImage *imageNOK = [UIImage imageNamed:@"red.png"];

      
    
    // Create the label and set its text
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(60,12,10,20)];
    [label setBackgroundColor:[UIColor clearColor]];
    
    r = arc4random() % 10;
    
 
    
    
    [label setText:[NSString stringWithFormat:@"%d",r]];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,10+(5*r),45)];
    [imageView setImage:imageOK];
    [imageView setAlpha:0.8];
    if(r<6) {
     [label setTextColor:[UIColor redColor]];
        [imageView setImage:imageNOK];
        [imageView setAlpha:1];


    }
    
    [self addSubview:label];
    [self addSubview:imageView];
    
    // Draw bar
    
   /* CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
    
    // Draw them with a 2.0 stroke width so they are a bit more visible.
    CGContextSetLineWidth(context, 2.0);
    
    CGContextMoveToPoint(context, 10+(2*r),0); //start at this point
    
    CGContextAddLineToPoint(context, 10+(2*r), 50); //draw to this point
    
    // and now draw the Path!
    CGContextStrokePath(context);*/
    //
    [super drawRect:rect];

    

    // Put it all together
   
}


@end
